package org.cp.dao.k8.impl;

import java.util.List;

import org.cp.dao.BaseDAO;
import org.cp.dao.k8.IK8ResultDAO;
import org.cp.vo.Prizenumber;
import org.cp.vo.Prizeresult;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class K8ResultDAO extends BaseDAO implements IK8ResultDAO {

	public void insertNumber(Prizenumber prizeNumber) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.save(prizeNumber);
		tx.commit();
		session.close();

	}

	public void insertResult(Prizeresult prizeResult) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.save(prizeResult);
		tx.commit();
		session.close();

	}

	public List selectNumber(String hql) {
		Session session = getSession();
		Query query = session.createQuery(hql);
		List numbers = query.list();
		if(numbers.size() != 0){
			return numbers;
		}
		session.close();
		return null;
	}

	public List selectResult(String hql) {
		Session session = getSession();
		Query query = session.createQuery(hql);
		List results = query.list();
		if(results.size() != 0){
			return results;
		}
		session.close();
		return null;
	}

	public void updataNumber(Prizenumber prizeNumber) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.update(prizeNumber);
		tx.commit();
		session.close();

	}

	public void updataResult(Prizeresult prizeResult) {
		Session session = getSession();
		Transaction tx = session.beginTransaction();
		session.update(prizeResult);
		tx.commit();
		session.close();
	}
}
